﻿using System;
using System.IO;

namespace ConsoleApplication15
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter address of local directory");
            string directory = Console.ReadLine();
            Console.WriteLine("Enter filename pattern (optional)");
            string filename = Console.ReadLine();
            DirectoryInfo dir = new DirectoryInfo(directory);
            Console.WriteLine("Directories in the current one");
            foreach (var item in dir.GetDirectories())
            {
                Console.WriteLine(item.Name);
                Console.WriteLine("Next level directories");
                foreach (var it in item.GetDirectories())
                    Console.WriteLine(it.Name);
                Console.WriteLine();
            }
            Console.WriteLine("Files in the current directory");
            foreach (var item in dir.GetFiles())
            {
                if (String.Equals("", filename))
                {
                    Console.WriteLine(item.Name);
                }
                else
                {
                    if (item.Name.Contains(filename))
                    {
                        Console.WriteLine(item.Name);
                    }
                }
            }
            Console.ReadLine();
        }
    }
}